<template>
  <div class="container" > 
       <top  :address="address"></top>
       <div class="allNav">
          <van-tabs @change="onClick" :active="active">  <!--sticky-->
            <van-tab
              v-for="(item,index) in allNav"
              :title="item.name"
              :key="index"
              :id="item.index"
            >
            
            <!-- 首页 -->
              <div v-if="item.index==1">
                 <div class="indexBanner"><swiper :imgUrls="banner"></swiper></div>
                 <div class="classify">
                     <!-- <navList :navList="indexNav" type="1"></navList> -->
                     <div class="Iconnav">
                          <div class="nav-item" v-for="(item,idx) in indexNav" :key="idx" >
                            <button v-if="item.name=='红包拿来'" class="getBag"  hover-class="none" open-type="getUserInfo" @getuserinfo="bindGetUserInfo($event,item.link)">
                                <img :src="item.icon" alt="">
                                <span>{{item.name}}</span>
                            </button>
                            <button @click="toLink(item.link)" v-else class="getBag" hover-class="none">
                                <img :src="item.icon" alt="">
                                <span>{{item.name}}</span>
                            </button>
                             
                          </div>
                      </div>
                 </div>
                 <div class="indexTit weui-cell">
                     <div><img src="/static/images/index/group.png" alt=""></div>
                     <div class="weui-cell__bd">拼拼优课</div>
                     <div class="weui-cell__ft" @click="tolist" data-url="../pinClass/main"> 更多 <img src="/static/images/index/moreS.png" alt="" class="more"></div>
                 </div>
                 <div ><courseList :kcList="item" v-for="(item,idx) in pingping" :key="idx" :type="1"></courseList></div>
                 
                 <div class="line"></div>
                 <div class="indexTit weui-cell">
                     <div><img src="/static/images/index/group.png" alt=""></div>
                     <div class="weui-cell__bd">砍价秒抢</div>
                     <div class="weui-cell__ft" @click="tolist" data-url="../bargainClass/main"> 更多 <img src="/static/images/index/moreS.png" alt="" class="more"></div>
                 </div>
                 <div><courseList :kcList="item"  v-for="(item,idx) in dis" :key="idx" :type="2"></courseList></div>
              </div>
            <!-- 关注-->
              <div v-if="item.index==2">
                  <div class="attention">
                      <scroll-view  style=" white-space: nowrap; display: flex;width:100%" scroll-x="true">
                          <div v-for="(item ,idx) in member" :key="idx" class="user">
                              <div>
                                 <avatar :avatar="item.avatar" :Level="item.partner_level" :userId="item.id" :isAuth="item.is_auth" :isPartner="item.is_partner"></avatar>
                              </div>
                            <span>{{item.nickname}}</span>
                          </div>
                      </scroll-view>
                  </div>
                  <div class="line"></div>
                  <div class="line"></div>
                   <ul>
                      <li  v-for="(item,idx) in attenList" :key="idx" >  
                        <div class="weui-cell originator" style="padding-bottom:0" v-if="item.user&&item.article_type!=10" >
                            <div class="weui-cell__hd">
                               <avatar :avatar="item.user.avatar" 
                                       :Level="item.user.partner_level" 
                                       :userId="item.user.id" 
                                       :isAuth="item.user.is_auth" 
                                       :isPartner="item.user.is_partner"></avatar>
                            </div>
                            <div class="weui-cell__bd">
                                <div class="nickname">{{item.user.nickname}}</div>   
                                <div class="time"> 
                                  <span v-if="item.user.role==1">家长</span>
                                  <span v-if="item.user.role==2">优秀老师</span>
                                  <span v-if="item.user.role==3">教育公司</span>
                                  <span v-if="item.user.role==4">教育媒体</span>
                                  <span v-if="item.user.role==5">其他</span>
                                  <span v-if="item.user.role==6">全日制学校</span> |
                                  <span style="color:#E9B55E" v-if="item.article_type=='3'">悬赏问答</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='4'">视频</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='5'">拼拼优课</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='6'">砍价秒抢</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='1'">专栏</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='2'">教育资讯</span>
                                </div>
                            </div>
                            <div class="weui-cell__ft">
                                 <report :info="item" type="1" model="1"></report>
                            </div>
                        </div>
                        <div  v-if="item.article_type=='3'"><!-- 悬赏问答-->
                            <questionlist :queList="item" type="2" isOperate="true"></questionlist>
                        </div>
                        <div v-if="item.article_type=='4'"  style="padding-top:10px;"><!-- 视频-->
                            <videoList :videoList="item" type="2" isOperate="true" :playIndex="playIndex" @videoPLay="videoPLay"></videoList>
                        </div>   
                        <div v-if="item.article_type=='5'"><!-- 拼拼课-->
                             <courseList :kcList="item"  :key="idx" :type="1"> </courseList>
                             <div class="weui-cell">
                                 <operate type="3" iszan="true" iscomt="true" isshare="true" :info="item"></operate> 
                             </div>
                             <div class="line"></div>
                        </div>
                        <div v-if="item.article_type=='6'"><!-- 拼拼课-->
                             <courseList :kcList="item"  :key="idx" :type="2"> </courseList>
                             <div class="weui-cell">
                                 <operate type="3" iszan="true" iscomt="true" isshare="true" :info="item"></operate> 
                             </div>
                             <div class="line"></div>
                        </div>
                        <div v-if="item.article_type=='1'"><!--  专栏-->
                             <special :specialList="item"  type="2" @click="likeclick" :isz="1" isOperate="true"></special>
                        </div>
                        <div v-if="item.article_type=='2'"><!--  教育资讯-->
                             <special :specialList="item"  type="2" @click="likeclick" :isz="0" isOperate="true"></special>
                        </div>
                        <div v-if="item.article_type=='9'" ><!--  良师益友-->
                            <starList :starList="item" ></starList>
                            <div class="line"></div>
                        </div>
                        <div v-if="item.article_type=='10'" class="goodT" ><!--  明星课堂-->
                            <teacher :teacher="item" type="2"></teacher>
                        </div>
                        <div v-if="item.article_type==11"><!--  推荐机构-->
                            <div class="indexTit weui-cell">
                                <div class="weui-cell__bd">推荐机构</div>
                            </div>
                            <div class='attentionList'>
                              <scroll-view scroll-x="true" style=" white-space: nowrap; display: flex;width:100%">
                                <div class='card' style="display: inline-block" v-for="(attItem,attIdx) in item.data" :key="attIdx" hover-class='none' @click='toOther' data-uid='item.id'>
                                  <div class='thumb'>
                                       <avatar :avatar="attItem.avatar" 
                                                :Level="attItem.partner_level" 
                                                :userId="attItem.id" 
                                                :isAuth="attItem.is_auth" 
                                                :isPartner="attItem.is_partner"></avatar>
                                  </div>
                                  <div class='caption'>
                                    <div class='name'>{{attItem.nickname}}</div>
                                    <div class='info' v-if="attItem.brief==null">还未有简介</div>
                                    <div class='info'  v-else>{{attItem.brief}}</div>
                                  </div>
                                  <Follow :info="attItem" :userId="attItem.id" ></Follow>
                                </div>
                              </scroll-view>
                            </div>
                            <div class="line"></div>
                        </div>
                      </li>
                  </ul>
              </div>
              <!-- 推荐 -->  
              <div v-if="item.index==3">
                  <ul>
                      <li  v-for="(item,idx) in recommend" :key="idx" >  
                        <div class="weui-cell originator" style="padding-bottom:0">
                            <div class="weui-cell__hd">
                               <avatar :avatar="item.user.avatar" 
                                       :Level="item.user.partner_level" 
                                       :userId="item.user.id" 
                                       :isAuth="item.user.is_auth" 
                                       :isPartner="item.user.is_partner"></avatar>
                            </div>
                            <div class="weui-cell__bd">
                                <div class="nickname">{{item.user.nickname}}</div>   
                                <div class="time"> 
                                  <span v-if="item.user.role==1">家长</span>
                                  <span v-if="item.user.role==2">优秀老师</span>
                                  <span v-if="item.user.role==3">教育公司</span>
                                  <span v-if="item.user.role==4">教育媒体</span>
                                  <span v-if="item.user.role==5">其他</span>
                                  <span v-if="item.user.role==6">全日制学校</span> |
                                  <span style="color:#E9B55E" v-if="item.article_type=='3'">悬赏问答</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='4'">视频</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='5'">拼拼优课</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='6'">砍价秒抢</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='1'">专栏</span>
                                  <span style="color:#E9B55E" v-if="item.article_type=='2'">教育资讯</span>
                                </div>
                            </div>
                            <div class="weui-cell__ft">
                                <report :info="item" type="1"  model="1"></report>
                            </div>
                        </div>
                        <div  v-if="item.article_type=='3'"><!-- 悬赏问答-->
                            <questionlist :queList="item" type="2" isOperate="true"></questionlist>
                        </div>
                        <div v-if="item.article_type=='4'"  style="padding-top:10px;"><!-- 视频-->
                            <videoList :videoList="item" :type="2" isOperate="true" :playIndex="playIndex" @videoPLay="videoPLay"></videoList>
                        </div>   
                        <div v-if="item.article_type=='5'"><!-- 拼拼课-->
                             <courseList :kcList="item"  :key="idx" :type="1"> </courseList>
                             <div class="weui-cell">
                                 <operate type="3" iszan="true" iscomt="true" isshare="true" :info="item"></operate> 
                             </div>
                             <div class="line"></div>
                        </div>
                        <div v-if="item.article_type=='6'"><!-- 拼拼课-->
                             <courseList :kcList="item"  :key="idx" :type="2"> </courseList>
                             <div class="weui-cell">
                                 <operate type="3" iszan="true" iscomt="true" isshare="true" :info="item"></operate> 
                             </div>
                             <div class="line"></div>
                        </div>
                        <div v-if="item.article_type=='1'"><!--  专栏-->
                             <special :specialList="item"  type="2" @click="likeclick" :isz="1" isOperate="true"></special>
                        </div>
                        <div v-if="item.article_type=='2'"><!--  教育资讯-->
                             <special :specialList="item"  type="2" @click="likeclick" :isz="0" isOperate="true"></special>
                        </div>
                        <div v-if="item.article_type=='9'" ><!--  良师益友-->
                            <starList :starList="item" ></starList>
                            <div class="line"></div>
                        </div>
                        <div v-if="item.article_type=='10'" class="goodT" ><!--  明星课堂-->
                            <teacher :teacher="item" type="2"></teacher>
                        </div>
                      </li>
                  </ul>
              </div>
              <!-- 视频 -->
              <div v-if="item.index==4">
                <div  v-for="(item,idx) in videolist" :key="idx">
                    <videoList :videoList="item"  isUser="true"  isOperate="true" :playIndex="playIndex" @videoPLay="videoPLay"></videoList>
                </div>
                  
              </div>

              <!-- 问答 -->
              <div v-if="item.index==6" >
                   <div class="questionBanner"><swiper :imgUrls="banner"></swiper></div>
                   <div class="specialNav">
                      <van-row>
                        <van-col span="6" v-for="(item,idx) in specialNav" :key="idx" @click="switchTab(idx,item.top,item.id)">
                          <div :class="currentSpecia==idx ? 'top-bar-active' : ''" v-if="idx!=2">
                              <span>{{item.name}}</span>
                              <img src="/static/images/price.jpg" alt="" class="icon" v-if="idx!=0&&item.top==0">
                              <img src="/static/images/jiang.jpg" alt="" class="icon" v-if="idx!=0&&item.top==1">
                              <img src="/static/images/sheng.jpg" alt="" class="icon" v-if="idx!=0&&item.top==2">
                          </div>
                        </van-col>
                      </van-row>
                   </div>
                   <div v-for="(item,idx) in questionlists" :key="idx" >
                       <questionlist :queList="item"  isOperate="true"></questionlist>
                   </div>
                   
              </div>
              <!-- 资讯 -->
              <div v-if="item.index==7">
                   <div class="special">
                       <swiper :imgUrls="banner"></swiper>
                   </div>
                   <div class="specialNav">
                      <van-row>
                        <van-col span="6" v-for="(item,idx) in specialNav" :key="idx" @click="switchTab(idx,item.top,item.id)">
                          <div :class="currentSpecia==idx ? 'top-bar-active' : ''"  v-if="idx!=4">
                              <span>{{item.name}}</span>
                              <img src="/static/images/price.jpg" alt="" class="icon" v-if="idx!=0&&item.top==0">
                              <img src="/static/images/jiang.jpg" alt="" class="icon" v-if="idx!=0&&item.top==1">
                              <img src="/static/images/sheng.jpg" alt="" class="icon" v-if="idx!=0&&item.top==2">
                          </div>
                        </van-col>
                      </van-row>
                   </div>
                    <div v-for="(item,idx) in edunews" :key="idx">
                        <special :specialList="item"   :isz="0" :type="1" isOperate="true"></special>
                    </div>
              </div>
              <!-- 专栏 -->
              <div v-if="item.index==5">
                   <div class="special">
                       <swiper :imgUrls="banner"></swiper>
                   </div>
                   <div class="specialNav">
                      <van-row>
                        <van-col span="6" v-for="(item,idx) in specialNav" :key="idx" @click="switchTab(idx,item.top,item.id)">
                          <div :class="currentSpecia==idx ? 'top-bar-active' : ''" v-if="idx!=4">
                              <span>{{item.name}}</span>
                              <img src="/static/images/price.jpg" alt="" class="icon" v-if="idx!=0&&item.top==0">
                              <img src="/static/images/jiang.jpg" alt="" class="icon" v-if="idx!=0&&item.top==1">
                              <img src="/static/images/sheng.jpg" alt="" class="icon" v-if="idx!=0&&item.top==2">
                          </div>
                        </van-col>
                      </van-row>
                   </div>
                    <div  v-for="(item,idx) in specialLists" :key="idx">
                        <special :specialList="item"  @click="clicklike" :idx="idx" :type="1" :isz="1"  isOperate="true"></special>
                    </div>
              </div>
              
              <div v-show="queS">
                  <img :src="img+'/que/no_conten@2x.png'" alt="" class="queS">
              </div>
              <div style="text-align:center" v-if="index!=0&&load==true"><van-loading /></div>
              <div style="text-align:center;font-size:20rpx" v-if="index!=0&&load==false&&currentpage!=1">我是有底线的</div>
            </van-tab>
          </van-tabs>
       </div>
  </div>
</template>

<script>
import card from "@/components/card";
import swiper from "@/components/swiper";
import navList from "@/components/nav";
import courseList from "@/components/list";
import special from "@/components/special";
import questionlist from "@/components/questionlist";
import videoList from "@/components/videoList"
import top from "@/components/top"
import avatar from "@/components/avatar"
import report from "@/components/report"
import Follow from "@/components/follow"
import teacher from "@/components/teacher"
import operate from "@/components/operate"
import starList from "@/components/starList";
import {getadrInfo} from "@/utils/getAdrInfo"
import {teacherList} from "@/api/teacher";
import {index} from '@/api/index'
import {spike} from '@/api/index' //首页砍价
import {ping} from '@/api/index' //首页砍价
import {recommend} from '@/api/index'
import {article} from '@/api/index'
import {edunews} from '@/api/index'
import {wenda} from '@/api/index'
import {attenTuijian} from '@/api/index'
import {attenMember} from '@/api/index'
import {attenList} from '@/api/index'
import {video} from '@/api/index'
import {otherINfo} from '@/api/other'
import {indexmenu} from '@/api/index'
import {indexnav} from '@/api/index'
import {indexads} from '@/api/index'
import { xdLogin } from "@/utils/login"
export default {
  
  components: {
    teacher,
    card,
    swiper,
    navList,
    courseList,
    special,
    questionlist,
    videoList,
    top,
    avatar,
    report,
    Follow,
    operate,
    starList,
  },
  data() {
    return { 
      value: "",
      img: this.$URL.imgurl,
      active: "0",
      motto: "活动结束",
      allNav: [],
      banner: [],
      indexNav: [
        {icon:"",name:"红包拿来",link:"/pages/getRedbag/main"}
      ],
      list: [],
      address:"", 
      specialNav:[
        {name:"推荐",id:"1",top:0,jiang:0,sheng:0},
        {name:"时间",id:"2",top:0,jiang:1,sheng:2},
        {name:"好评",id:"3",top:0,jiang:3,sheng:4},
        {name:"粉丝",id:"4",top:0,jiang:5,sheng:6},
        {name:"金额",id:"5",top:0,jiang:7,sheng:8},
      ],
      currentSpecia:0,//专栏
      currentQuestion:0,//问答
      specialLists:[],
      questionlists: [],
      videolist:[],
      pingping:[],
      dis:[],
      columnStatus:0,
      load:false,
      edunews:[],
      member:[],
      recommend:[],
      teacher:[],
      qcode:0,
      user_id:0,
      attenList:[],
      articleType:1,
      queS:false,
      currentIndex:0,
      currentpage:1,
      teacherList:"",
      playIndex:null,
      coordinate:{
        longitude:0,
        latitude:0
      },
      videoContext:null 
    }
  },


  methods: {
      bindGetUserInfo(e,url){
        wx.getStorage({
            key: 'token',
            success: (result) => {
                mpvue.navigateTo({url});
            },
            fail: () => {
                xdLogin(e).then((res)=>{
                    mpvue.navigateTo({url});
                })
            },
            complete: () => {}
        });
    },
    onClick(e){
      console.log(e)
      if(this.playIndex){
          this.videoContext = wx.createVideoContext('video' + this.playIndex)
          this.videoContext.pause()
          console.log(this.videoContext)
          this.videoContext=null
          console.log(this.videoContext)
          
      }
        
        this.active=e.target.index;
        this.currentIndex=e.target.index;
        this.queS=false
        this.load=false
        this.currentpage=1;
        this.currentSpecia=0;
        this.columnStatus=0;
        this.currentQuestion=0;
        this.banner=[]
        this.videolist=[]
        this.questionlists=[]
        this.edunews=[]
        this.specialLists=[]
        let idx=e.target.index;
        let navIdx=this.allNav[idx].index
        if(navIdx==4){
          this.articleType=4
        }else if(navIdx==6){
          this.articleType=3
          this.getads(5)
        }else if(navIdx==7){
          this.articleType=2
          this.getads(10)
        }else if(navIdx==5){
          this.articleType=1
          this.getads(3)
        }else{
          this.getads(1)
        }
        this.specialNav=[
          {name:"推荐",id:"1",top:0,jiang:0,sheng:0},
          {name:"时间",id:"2",top:0,jiang:1,sheng:2},
          {name:"好评",id:"3",top:0,jiang:3,sheng:4},
          {name:"粉丝",id:"4",top:0,jiang:5,sheng:6},
          {name:"金额",id:"4",top:0,jiang:7,sheng:8},
        ],
        this.getlist();
    },
    tolist(e){
       var url=e.currentTarget.dataset.url;
       console.log(url)
       mpvue.navigateTo({url})
    },
    clickHandle(ev) {
      console.log("clickHandle:", ev);
      // throw {message: 'custom test'}
    },
    // 喜欢
    likeclick(){
         console.log(1)
         console.log("这是父组件的"+data)
    },
    // 关注
   
    switchTab(idx,top,id){
      this.questionlists=[]
      this.edunews=[]
      this.specialLists=[]
      var currentSpecia = this.currentSpecia;
      var idx = idx;
      var id = id;
      var Top=top;
      var specialNav = this.specialNav;
      this.currentpage=1;
      if(Top==0){
        top=1
      }else if(Top==1){
        top = 2
      } else if (Top == 2) {
        top = 1;
      }
      specialNav[idx].top=top
      if ((currentSpecia == idx) && (idx==0)){
        this.columnStatus=0;
        console.log(this.columnStatus)
        this.getlist()
        return;
      }else{
        for (var i = 0; i < specialNav.length; i++) {
          specialNav[i].top = 0
        }
        specialNav[idx].top = top;
        if(top==1){
           this.columnStatus=specialNav[idx].jiang 
        }else if(top==2){
          this.columnStatus=specialNav[idx].sheng 
        }
        this.specialNav=specialNav
        this.currentSpecia=idx;
        this.getarticle()
        console.log(this.columnStatus)
      }
    },
    signDesk(){
      console.log(1)
      let url = '../signDesk/main'
      mpvue.navigateTo({url});
    },
    scroll(){
       console.log(1)
    },
    // 获取首页信息
    getIndex(){
      let data={} 
      data.zip=this.qcode;
      data.user_id=this.user_id;
      spike(data).then(res=>{
        let spike = res.data.data
        this.dis=this.simplify(spike,6)
      })
      ping(data).then(res=>{
        
        let ping = res.data.data;
        this.pingping=this.simplify(ping,5)
      })
      indexnav().then(res=>{
        console.log(res.data)
        this.allNav=res.data
      })
      indexmenu().then(res=>{
        this.indexNav=res.data
      })
      this.getads(1)
    },
    getads(spaceid){
      indexads({spaceid:spaceid,zip:this.qcode}).then(res=>{
        this.banner=res.data
      })
    },
    getrecommend(){
      let data={};
      data.page=this.currentpage;
      data.zip=this.qcode;
      data.user_id=this.user_id;
      data.lng=this.coordinate.longitude;
      data.lat=this.coordinate.latitude;
      recommend(data).then(res=>{
        if(res.code==200){
          let last_page=res.data.total_page
          if(this.currentpage==1){
              console.log(res.data.data)
              this.recommend=this.simplify(res.data.data)
          }else{
              this.recommend=this.recommend.concat(this.simplify(res.data.data)) 
          }
          console.log(this.recommend)
          if (last_page > this.currentpage){
              this.load=true
          }else{
              this.load=false
          }
        }else if(res.code==201){
          this.queS=true
        }
          
      })
    },
    getarticle(){
      let data={};
      data.status=this.columnStatus;
      data.page=this.currentpage;
      data.type=this.articleType; 
      data.user_id=this.user_id;
      article(data).then(res=>{
        if(res.code==200){
          let last_page=res.data.data.last_page;
          
           switch (this.articleType) {
              case 1:
                this.specialLists=this.specialLists.concat(this.simplify(res.data.data.data));
                break;
              case 2:
                this.edunews=this.edunews.concat(this.simplify(res.data.data.data));
                break;
              case 3:
                this.questionlists=this.questionlists.concat(this.simplify(res.data.data.data));
                break;
              case 4:
                this.videolist=this.videolist.concat(this.simplify(res.data.data.data));
                break;    
              default:
                break;
            }
          
        console.log(last_page)
        console.log(this.currentpage)
          if (last_page > this.currentpage){
              this.load=true
          }else{
              this.load=false
          }
        }else{
           this.queS=true
        }
      }).catch(res=>{
          this.queS=true
      })
    },  
    getlist() {
      switch(this.currentIndex){
        case 0:
          this.getIndex()       //首页
          break;
        case 1:
          this.getattenMember()
          this.getattenList()
          break;
        case 2:
          this.getrecommend()   //推荐
          break;      
        default:
          this.getarticle()
        console.log("d");  //若变量与所有的变量值不同，则执行该处的代码
      }
    },
    getattenMember(){
      attenMember({user_id:this.user_id}).then(res=>{
         this.member=res.data
      })
    },
    getattenList(){
      let data={};
      data.page=this.currentpage
      data.user_id=this.user_id;
      data.zip=this.qcode;
      data.lng=this.coordinate.longitude;
      data.lat=this.coordinate.latitude;
      attenList(data).then(res=>{
          console.log(res)
          if(res.code==200){
            let last_page=res.data.total_page;
            if(this.currentpage==1){
              
              this.attenList=this.simplify(res.data.data)
            }else{
              this.attenList=this.attenList.concat(this.simplify(res.data.data));
            }
            console.log(this.attenList)
            if (last_page > this.currentpage){
                this.load=true
            }else{
                this.load=false
            }
          }else{
             this.queS=true
          }
      })
    },
    videoPLay(data){
      let id=data.id
      if (!this.playIndex) {
        this.playIndex=id;
        this.videoContext = wx.createVideoContext('video' + id)
        console.log(this.videoContext)
        this.videoContext.play()
      } else { 
          this.videoContext = wx.createVideoContext('video' + this.playIndex)
          this.videoContext.seek(0)
          this.videoContext.pause()
          this.playIndex= id;
          this.videoContext = wx.createVideoContext('video' + this.playIndex)
          this.videoContext.play()
        }
      },
     // 精简页面信息
    simplify(list) {
        return list.map(item => {
            switch (parseInt(item._source.article_type)) {
              case 1: 
                  return {
                      id: item._source.id,
                      title: item._source.title,
                      images: item._source.images,
                      is_zan: item._source.is_zan,
                      comments: item._source.comments,
                      zans: item._source.zans, 
                      created_at: item._source.created_at,
                      user: item._source.user,
                      article_type: 1,
                  }
                break;
               case 2: 
                  return {
                      id: item._source.id,
                      title: item._source.title,
                      images: item._source.images,
                      is_zan: item._source.is_zan,
                      comments: item._source.comments,
                      zans: item._source.zans, 
                      created_at: item._source.created_at,
                      user: item._source.user,
                      article_type: 2,
                  }
                break;
                case 3:
                  return {
                    id: item._source.id,
                    user: item._source.user,
                    article_type: item._source.article_type,
                    questions: item._source.questions,
                    reword: item._source.reword,
                    is_zan: item._source.is_zan,
                    thumb: item._source.thumb,
                    comments: item._source.comments,
                    zans: item._source.zans,
                    article_type: 3,
                  }
                break;
               case 4:
                  return {
                    id: item._source.id,
                    user: item._source.user,
                    article_type: item._source.article_type,
                    video_desc: item._source.video_desc,
                    video: item._source.video,
                    is_zan: item._source.is_zan,
                    thumb: item._source.thumb,
                    comments: item._source.comments,
                    zans: item._source.zans,
                    article_type: 4,
                  }
                break;  
                
              case 5:
                return {
                  title: item._source.title,
                  id: item._source.id,
                  thumb: item._source.thumb,
                  prime_price: item._source.prime_price,
                  price: item._source.price,
                  fx_sta: item._source.fx_sta,
                  discount: item._source.discount,
                  user: item._source.user,
                  article_type: 5,
                  comments: item._source.comments,
                  zans: item._source.zans,
                  is_zan: item._source.is_zan,
                }
                break;
              case 6:
                return {
                  title: item._source.title,
                  id: item._source.id,
                  thumb: item._source.thumb,
                  prime_price: item._source.prime_price,
                  price: item._source.price,
                  fx_sta: item._source.fx_sta,
                  discount: item._source.discount,
                  nums: item._source.nums,
                  user: item._source.user,
                  article_type:6,
                  comments: item._source.comments,
                  zans: item._source.zans,
                  is_zan: item._source.is_zan,
                  start:item._source.start,
                }
                break;
                default:
                return item._source;
            }
        })
    },
    toLink(url){
      mpvue.navigateTo({url});
    }

  },

  created() {
    
      
    
  },
  mounted(){
    var that=this;
    wx.getStorageSync("user_info")?this.user_id=wx.getStorageSync("user_info").id:'';
    wx.getStorageSync("coordinate")?this.coordinate=wx.getStorageSync("coordinate"):'';
    wx.getStorage({
      key: 'address',
      success: (result) => {
        console.log(result)
         that.address=result.data;
         that.qcode= wx.getStorageSync("qcode");
      },
      fail: () => {
        getadrInfo().then(res=>{
          var desc = res[0].regeocodeData.addressComponent.city;
          var adcode = res[0].regeocodeData.addressComponent.adcode;
          that.address=desc
          that.qcode= adcode
          that.getlist();
        })
      },
      complete: () => {
        that.getlist();
      }
    });
  },

  


  onReachBottom(){
    if(this.load){
      // setTimeout(() => {
            this.currentpage++
            this.getlist()
      // },1500)
       
    }
  },
  onPullDownRefresh() {
    wx.showNavigationBarLoading(); //在标题栏中显示加载
    setTimeout(() => {
      this.currentpage=1
      this.getlist();
      wx.hideNavigationBarLoading(); //完成停止加载
      wx.stopPullDownRefresh(); //停止下拉刷新
    }, 1500);
  },
};
</script>

<style  lang="scss">
.allNav {
  .van-tab {
    background: #f4f5f5;
    font-size: 15px;
    color: #333;
    line-height: 33px;
  }
  .van-tab--active {
    color: #1a84fb;
  }
  .van-tabs--line {
    padding-top: 33px;
    .van-tabs__wrap {
      height: 33px;
    }
  }

  .van-tabs__line {
    display: none;
  }
  
  .classify .Iconnav{
      width: 100%;
      padding:8px 0;
      .nav-item{
          display: inline-block;
          text-align: center;
          margin-top:10px;
          width:25%;
          img{
              width:40px;
              height:40px;
              display: block;
              margin: 0 auto;
          }
          span{
              font-size:12px;
              color:rgba(51,51,51,1);
              line-height:18px;
          }
          .getBag{
              padding:0;
              margin:0;
              background:none;
              display:block;
              line-height:normal;
              &::before{
                border:none;
              }
              &::after{
                border:none;
              }
          }
      } 
  }
  .van-tabs__wrap--scrollable .van-tab {
    -webkit-flex:0 0 14.28%!important;
    flex:0 0 14.28% !important;
  }
}
.indexBanner swiper{
  height: 188px;
  img{
    height: 188px;
  }
}
.attentionList{
  .Follow{
    margin-top: 10px;
  }
}
.goodT{
  border-bottom: 10rpx solid #f4f5f5;
  .teacherList{
    border: none;
    .user{
      padding: 0
    }
    .property {
      padding-top: 15px;
    }
  }
}
</style>
<style lang="scss" >
.queS{
    width:417rpx;
    height:324rpx;
    display:block;
    margin:50px auto;
}
.line {
  width: 375px;
  height: 5px;
  background: rgba(244, 245, 245, 1);
}
.indexTit {
  font-size: 17px;
  font-weight: bold;
  color: rgba(51, 51, 51, 1);
  img {
    width: 15px;
    height: 13px;
    vertical-align: middle;
    margin-right: 6px;
  }
  .more {
    width: 10px;
    height: 10px;
    margin-right: 0;
  }
  .weui-cell__bd {
    font-size: 17px;
  }
  .weui-cell__ft {
    color: #1a84fb;
    font-size: 14px;
  }
}
.attention{
  background:rgba(255,255,255,1);
  .user{
     padding:10px 8px;
     text-align:center;
     font-size:12px;
     color:#333;
     display: inline-block;
     width:55px;
      .Avatar{
        width:110rpx;
        height:110rpx;
        border-radius:50%;
        .avatar{
          width:110rpx;
          height:110rpx;
        }

      }  
      span{
        display: inline-block;
        overflow: hidden;
        width:100%;
        text-overflow:ellipsis;
        white-space: nowrap;
      }
  }
}
.attentionList{
  .card{
    width:301rpx;
    height:400rpx;
    background:rgba(255,255,255,1);
    box-shadow:2rpx 2rpx 10rpx 0px rgba(19,19,19,0.13);
    border-radius:10rpx;
    margin: 20rpx 10rpx;
    margin-bottom: 30rpx;
    padding: 40rpx;
    padding-bottom: 0;
    box-sizing: border-box;
  }
  .card:nth-child(1){
    margin-left: 30rpx;
  }
  .card:nth-last-child(1){
    margin-right: 30rpx;
  }
  .card .thumb{
    margin: 0 auto;
    width:110rpx;
    height:110rpx;                                                                                                                               
  }
  .card .thumb .Avatar{
    width:100rpx;
    height:100rpx;
    border-radius:50%;
    .avatar{
      width:100rpx;
      height:100rpx;
    }
  }
  .caption .name{
    font-size:28rpx;
    font-weight:bold;
    color:rgba(51,51,51,1);
    line-height:1;
    text-align: center;
    margin-top: 20rpx;
  }
  .caption .info{
    font-size:24rpx;
    font-weight:500;
    color:rgba(102,102,102,1);
    text-align: center;
    margin-top: 25rpx;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space:initial;
  }
}
.specialNav{
  font-size:14px;
  font-weight:500;
  color:rgba(51,51,51,1);
  text-align:center;
  height:40px;
  background:rgba(255,255,255,1);
  box-shadow:0px 2px 4px 1px rgba(0, 0, 0, 0.07);
  line-height:40px;
  .icon{
    width:4px;
    height:9px;
    margin-left:1px;
  }
  .top-bar-active{
    color:#1A84FB;
  }
}
</style>
